package com.example.easyutils.mainpage;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


import com.example.easyutils.R;
import com.example.easyutils.watermark.ClearWatermark;

import java.util.List;

public class GridAdapter extends ArrayAdapter {
    private TextView name;
    private ImageView imageView;
    private Context context;
    private int resourceId;
    public GridAdapter(@NonNull Context context, @NonNull List objects) {
        super(context, R.layout.card_item,objects);
        this.resourceId = R.layout.card_item;
        this.context = context;
    }

//    public GridAdapter(List mList, ClearWatermark clearWatermark) {
//        super();
//    }


    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        GridUtil gridUtil = (GridUtil) getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        Log.d("test",gridUtil.getName());
        Log.d("test",gridUtil.getImage()+"");
        name = (TextView)view.findViewById(R.id.garbage_text);
        imageView = (ImageView) view.findViewById(R.id.garbage_image);
        name.setText(gridUtil.getName());
        imageView.setImageResource(gridUtil.getImage());
//        Glide
//                .with(context)
////                .apply(RequestOptions.placeholderOf(R.drawable.img2).dontAnimate().override(800, 800))
//                .load(gridUtil.getImage())
//                .into(imageView);
        return view;
    }
}
